<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; UTF-8">
<base href="${ctx }/">
<title>司机位置</title>
<style type="text/css">
  #map{
  height:800px;
  width:100%
  }
</style>
</head>
<body>
<div id="map">
</div>
</body>
<script src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
	var mapData = {};
	var map = {}; 
   function initMap(){
	  var uluru={lat:-25.363,lng:131.044};
	   map = new google.maps.Map(document.getElementById('map'),{
		   zoom:4,
		   center:uluru
	   });
	  /*  var marker = new google.maps.Marker({
		   position:uluru,
		   map:map
	   }); */
	   
	   
	   $.ajax({
           type: "get",
           url: "http://54.66.146.242:8080/fab_api/gisRecord/getAllDriverPosition",
           async:false,
           success: function(data){    	            	 
          if(data.code==200){
        	  console.log(data)
        	  mapData = data.data;
        	//  createMap();
        	  var script = document.createElement('script');
        	  document.getElementsByTagName('head')[0].appendChild(script);
    	       }else{
    	    	    layer.msg(data.msg);
    	       }
                    }
       });
	   
	   for (var i = 0; i < mapData.length; i++) {
		   
	       	var len = JSON.parse(mapData[i]).length;
	       	var mapArr = JSON.parse(mapData[i])[len-1];
	       	console.log(mapArr);
	      	var coords = mapArr.split(",");
	         var latLng = new google.maps.LatLng(coords[1],coords[0]);
	         var marker = new google.maps.Marker({
	           position: latLng,
	           map: map
	         });
	         uluru={lat:coords[1],lng:coords[0]};
	       } 
	   
   }
   //  url: "http://52.62.187.44:8080/fab_api/gisRecord/getAllDriverPosition",
  /*  window.eqfeed_callback = function(results) {
	   for (var i = 0; i < results.data.length; i++) {
	         var coords1 = data.data[i];
	         var co = coords1.split("\\\"");
	         var c= co[co.length-1];
	         var coords =coords1.split(',');
	         console.log(coords)
	         var latLng = new google.maps.LatLng(coords[1],coords[0]);
	         var marker = new google.maps.Marker({
	           position: latLng,
	           map: map
	         });
	       } 
     } */
   
     
     
</script>
<!-- <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBF5UoTfpN877xWxSreNi7ROOw6rbNDiRo&callback=initMap"></script> -->
<script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDnirlzWmC0tOipZsE8zk_94caVAk2e0JI&callback=initMap"></script> 

</html>